package com.qujia.customer.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qujia.customer.domain.StationReturnCashUse;
import com.qujia.customer.mapper.StationReturnCashUseMapper;
import com.qujia.customer.service.IStationReturnCashUseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class StationReturnCashUseImpl extends ServiceImpl<StationReturnCashUseMapper, StationReturnCashUse>
        implements IStationReturnCashUseService {

    @Override
    @Transactional
    public void batchUpdateOrInsert(List<StationReturnCashUse> stationReturnCashUses,String createBy) {
        for (StationReturnCashUse item : stationReturnCashUses) {
            if (item.getId() == null){
                item.setCreateTime(new Date());
                item.setCreateBy(createBy);
                baseMapper.insert(item);
            } else {
                item.setUpdateTime(new Date());
                item.setUpdateBy(createBy);
                baseMapper.updateById(item);
            }
        }
    }

    @Override
    public boolean removeByID(Long id) {
        return baseMapper.removeByID(id) > 0;
    }
}
